# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)
if User.find_by(mobile: "13412341234").nil?
  User.create(name: "张三",
              mobile: "13412341234",
              password: "123456",
              password_confirmation: "123456",
              user_type: USER_TYPE["信息录入员"])
end
if User.find_by(mobile: "13512341234").nil?
  User.create(name: "后台管理1",
              username: "admin1",
              mobile: "13512341234",
              password: "123456",\
              password_confirmation: "123456",
              user_type: USER_TYPE["后台管理员"])
end
if Merchant.find_by(name: "四季鲜果").nil?
  Merchant.create_with_images(name: "四季鲜果",
              phone: "多个电话用逗号或空格分隔",
              business_scope: "水果",
              merchant_type: "1",
              longitude: "116.354251",
              latitude: "39.974677",
              location: "双榆树北里",
              is_dtd: "true",
              service_start: "08:00",
              service_end: "23:00",
              information_clerk_id: "1",
              images: [
                "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCADcANwDASIAAhEBAxEB/8QAGwABAAIDAQEAAAAAAAAAAAAAAAUGAQMEAgf/xAA+EAACAgECAQYKCAUFAQAAAAAAAQIDBAURIRIUMUFRcRMVIjJUYYGRscEjNDVSYnOS0QYzgqHhFkJyg/Ek/8QAGgEBAAIDAQAAAAAAAAAAAAAAAAQFAQMGAv/EADcRAAICAQIDBAgEBQUAAAAAAAABAgMEBRESITETQVHRFCIyUmFxgZEVocHwIzNyseEkNDVCRP/aAAwDAQACEQMRAD8A+/gAAAAAAAAA8WW11Qc7JqMV0tkLl67s3HFjv+OS+CIuTmU4y3sf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B2P//Z"
              ])
end


ms = [
{
  'name' => '十字坡酒店',
  'phone' => '010-12312312',
  'business_scope' => '人肉包子',
  'merchant_type' => '1',
  'longitude' => '116.32723',
  'latitude' => '39.973792',
  'location' => '十字坡一号',
  'is_dtd' => true,
  'service_start' => '08:30',
  'service_end' => '23:30',
  'information_clerk_id' => '1'
},
{
  'name' => '老李水果店',
  'phone' => '010-11112222',
  'business_scope' => '水果',
  'merchant_type' => '1',
  'longitude' => '116.32723',
  'latitude' => '39.973792',
  'location' => '人民大学东门',
  'is_dtd' => true,
  'service_start' => '08:30',
  'service_end' => '23:30',
  'information_clerk_id' => '1'
},
{
  'name' => '好友来电器维修',
  'phone' => '010-12312312',
  'business_scope' => '电器维修',
  'merchant_type' => '1',
  'longitude' => '116.32723',
  'latitude' => '39.973792',
  'location' => '双榆树北里',
  'is_dtd' => true,
  'service_start' => '08:30',
  'service_end' => '23:30',
  'information_clerk_id' => '1'
},
{
  'name' => '苏东坡肘子',
  'phone' => '010-12312312',
  'business_scope' => '肘子',
  'merchant_type' => '1',
  'longitude' => '116.32723',
  'latitude' => '39.973792',
  'location' => '海淀黄庄地铁站',
  'is_dtd' => true,
  'service_start' => '08:30',
  'service_end' => '23:30',
  'information_clerk_id' => '1'
}
]

images = [
{
  'url' => '/assets/images/1.jpg',
  'owner' => 1,
  'image_type' => "2"
},
{
  'url' => '/assets/images/2.jpg',
  'owner' => 1,
  'image_type' => "2"
},
{
  'url' => '/assets/images/3.jpg',
  'owner' => 1,
  'image_type' => "2"
},
{
  'url' => '/assets/images/4.jpg',
  'owner' =>2,
  'image_type' => "2"
},
{
  'url' => '/assets/images/5.jpg',
  'owner' => 3,
  'image_type' => "2"
},
{
  'url' => '/assets/images/6.jpg',
  'owner' => 4,
  'image_type' => "2"
},
{
  'url' => '/assets/images/7.jpg',
  'owner' => 5,
  'image_type' => "2"
},
{
  'url' => '/assets/images/8.jpg',
  'owner' => 2,
  'image_type' => "2"
},
{
  'url' => '/assets/images/1.jpg',
  'owner' => 1,
  'image_type' => "3"
}
]

if Merchant.find_by(name: "十字坡酒店").nil?
  ms.each do |m|
    Merchant.create(m)
  end
end

if Image.find_by(url: "/assets/images/4.jpg").nil?
  images.each do |i|
    Image.create(i)
  end
end

demands = [
  {
    title: "陈大富：地板维修1",
    description: "test1",
    status: 0,
    creator_id: 1
  },
  {
    title: "陈大富：地板维修2",
    description: "test2",
    status: 0,
    creator_id: 1
  }
]

if Demand.find_by(title: "陈大富：地板维修").nil?
  demands.each do |d|
    Demand.create(d)
  end
end

messages = [
  {
    sender_id: 1,
    receiver_id: 2,
    demand_id: 1,
    content: "nihao"
  },
  {
    sender_id: 2,
    receiver_id: 1,
    demand_id: 1,
    content: "good"
  },
  {
    sender_id: 2,
    receiver_id: 1,
    service_id: 1,
    content: "lala"
  }
]

if Message.find_by(content: "nihao").nil?
  messages.each do |d|
    Message.create(d)
  end
end